﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Utils.MathUtilitys
{
    public class CollisionUtils
    {
        public static bool CircleLine(Vector2 lineP0, Vector2 lineP1, Vector2 circle, float radius)
        {
            Vector2 ab = lineP1 - lineP0;
            float t = MathUtils.Cap(Vector2.Dot(circle - lineP0, ab) / ab.LengthSquared(), 0, 1);
            float disSqr = (lineP0 + ab * t - circle).LengthSquared();

            return disSqr <= radius * radius;
        }
    }
}
